//
//  SLAboutMeViewController.m
//  SaltLightDemo
//
//  Created by lzy on 2018/4/25.
//  Copyright © 2018年 lzy. All rights reserved.
//

#import "SLAboutMeViewController.h"
#import "UINavigationController+FDFullscreenPopGesture.h"

#import "PersonalSituationViewController.h"
#import "ModifyPasswordViewController.h"

#import "ApplicationCompletionViewController.h"
#import "SingInViewController.h"
#import "MGRequestService+My.h"
#import "SingInViewController.h"
// iPhone X 宏定义
#define  iPhoneX (SCREEN_WIDTH == 375.f && SCREEN_HEIGHT == 812.f ? YES : NO)
// 适配iPhone X 状态栏高度
#define  MC_StatusBarHeight      (iPhoneX ? 120.f : 87.f)
@interface SLAboutMeViewController ()
@property (nonatomic , strong) UILabel *nameLabel;
@property (nonatomic , strong) UIButton *loginOutBtn;
@end

@implementation SLAboutMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我";
    self.fd_prefersNavigationBarHidden = YES;
    [self initUI];
    
    // Do any additional setup after loading the view.
}

-(void)initUI
{
    UIImageView * image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH*195.0/375)];
    image.image = [UIImage imageNamed:@"Gridzzly"];
    [self.view addSubview:image];
    
    UIImageView * image1 = [[UIImageView alloc]init];
    image1.frame = CGRectMake((SCREEN_WIDTH-SCREEN_WIDTH*70.0/375.0)/2, (image.frame.size.height-SCREEN_WIDTH*70.0/375.0)/2, SCREEN_WIDTH*70.0/375.0, SCREEN_WIDTH*70.0/375.0);
    image1.layer.masksToBounds = YES;
    image1.layer.cornerRadius = SCREEN_WIDTH*70.0/375.0/2;
    image1.layer.borderColor = [UIColor whiteColor].CGColor;
    image1.layer.borderWidth = 6.0;
    
    image1.image = [UIImage imageNamed:@"icon"];
    [image addSubview:image1];
    
    
    
    UILabel * l = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-100)/2, CGRectGetMaxY(image1.frame)+15, 100, 20)];
    l.font = [UIFont boldSystemFontOfSize:16.0];
    self.nameLabel = l;
    l.text = @"有钱优借";
    l.textColor = [UIColor add_colorWithRGBHexString:@"333333"];
    l.textAlignment = NSTextAlignmentCenter;
    [image addSubview:l];
    
    UILabel * l1 = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-100)/2, CGRectGetMaxY(l.frame), 100, 20)];
    l1.font = [UIFont systemFontOfSize:12.0];
    l1.text = @"您好";
    l1.textColor = [UIColor add_colorWithRGBHexString:@"333333"];
    l1.textAlignment = NSTextAlignmentCenter;
    [image addSubview:l1];
    
    UIView * view1 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(image.frame)+20, SCREEN_WIDTH, 110)];
    view1.backgroundColor = [UIColor add_colorWithRGBHexString:@"FFFFFF"];
    [self.view addSubview:view1];
    
    UIView * line1 = [[UIView alloc]initWithFrame:CGRectMake(30, 55, SCREEN_WIDTH-60, 1.0)];
    line1.backgroundColor = [UIColor add_colorWithRGBHexString:@"EFEFF4"];
    [view1 addSubview:line1];
    
    UIImageView * image2 = [[UIImageView alloc]initWithFrame:CGRectMake(25, 15, 25, 25)];
    image2.image = [UIImage imageNamed:@"per_icon_grjbqk"];
    [view1 addSubview:image2];
    
    UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(image2.frame)+10, 10, 100, 35)];
    label1.font = [UIFont boldSystemFontOfSize:14.0];
    label1.text = @"个人基本情况";
    label1.textColor = [UIColor add_colorWithRGBHexString:@"333333"];
    label1.textAlignment = NSTextAlignmentLeft;
    [view1 addSubview:label1];
    
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 55)];
    [btn addTarget:self action:@selector(grqk:) forControlEvents:UIControlEventTouchUpInside];
    [view1 addSubview:btn];
    
    
    UIImageView * icon1 = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-15-29, 20, 15, 15)];
    icon1.image = [UIImage imageNamed:@"app_icon_more"];
    [view1 addSubview:icon1];
    
    UIImageView * image3 = [[UIImageView alloc]initWithFrame:CGRectMake(25, 15+55, 25, 25)];
    image3.image = [UIImage imageNamed:@"per_icon_xgmm"];
    [view1 addSubview:image3];
    
    UILabel * label2 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(image2.frame)+10, 10+55, 100, 35)];
    label2.font = [UIFont boldSystemFontOfSize:14.0];
    label2.text = @"修改密码";
    label2.textColor = [UIColor add_colorWithRGBHexString:@"333333"];
    label2.textAlignment = NSTextAlignmentLeft;
    [view1 addSubview:label2];
    
    UIImageView * icon2 = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-15-29, 20+55, 15, 15)];
    icon2.image = [UIImage imageNamed:@"app_icon_more"];
    [view1 addSubview:icon2];
    
    UIButton * btn1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 55, SCREEN_WIDTH, 55)];
    [btn1 addTarget:self action:@selector(xgmm:) forControlEvents:UIControlEventTouchUpInside];
    [view1 addSubview:btn1];
    
    UIView * view11 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(view1.frame)+20, SCREEN_WIDTH, 55)];
    view11.backgroundColor = [UIColor add_colorWithRGBHexString:@"FFFFFF"];
    [self.view addSubview:view11];
    
    
    UIImageView * image4 = [[UIImageView alloc]initWithFrame:CGRectMake(25, 15, 25, 25)];
    image4.image = [UIImage imageNamed:@"per_icon_dhlx"];
    [view11 addSubview:image4];
    
    UILabel * label3 = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(image2.frame)+10, 10, 100, 35)];
    label3.font = [UIFont boldSystemFontOfSize:14.0];
    label3.text = @"联系电话客服";
    label3.textColor = [UIColor add_colorWithRGBHexString:@"333333"];
    label3.textAlignment = NSTextAlignmentLeft;
    [view11 addSubview:label3];
    
    UIImageView * icon3 = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-15-29, 20, 15, 15)];
    icon3.image = [UIImage imageNamed:@"app_icon_more"];
    [view11 addSubview:icon3];
    
    UIButton * btn2 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 55)];
    [btn2 addTarget:self action:@selector(lxkf:) forControlEvents:UIControlEventTouchUpInside];
    [view11 addSubview:btn2];
    
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 250)/2.0, SCREEN_HEIGHT-MC_StatusBarHeight-40, 250, 40)];
    self.loginOutBtn = button;
    button.backgroundColor = [UIColor whiteColor];
    [button setTitle:@"退出" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:14.0];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius = 20;
    [self.view addSubview:button];
    
}
-(void)grqk:(UIButton * )btn{
    if (UserInfoManage.userInfo.token)
    {
       [self.navigationController pushViewController:[[PersonalSituationViewController alloc]init] animated:YES];
    }else
    {
        [self.navigationController pushViewController:[[SingInViewController alloc]init] animated:YES];
    }
    
}
-(void)xgmm:(UIButton * )btn{
    if (UserInfoManage.userInfo.token)
    {
       [self.navigationController pushViewController:[[ModifyPasswordViewController alloc]init] animated:YES];
    }else
    {
        [self.navigationController pushViewController:[[SingInViewController alloc]init] animated:YES];
    }
    
}
-(void)lxkf:(UIButton * )btn{
    [Util callAtOnce:@"400-700-1996"];

}
-(void)back:(UIButton * )btn{
    self.loginOutBtn.hidden = YES;
    UserInfoManage.userInfo.token = nil;
    UserInfoManage.userInfo.nickName = nil;
//    UserInfoManage.userInfo.age = 0;
//    UserInfoManage.userInfo.workStauts = 0;
//    UserInfoManage.userInfo.sociaSecurity = 0;
//    UserInfoManage.userInfo.accumulationFund = 0;
//    UserInfoManage.userInfo.haveHouse = 0;
//    UserInfoManage.userInfo.haveCar = 0;
//    UserInfoManage.userInfo.headImg = 0;
    self.nameLabel.text = @"蜜蜂优借";
    UserInfoManage.userInfo=UserInfoManage.userInfo;
    [MGRequestService configeWithuserInfo:nil]; // 重新配置网络请求参数
    [self showToastInViewController:@"退出登录"];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    if (UserInfoManage.userInfo.nickName) {
        self.nameLabel.text = UserInfoManage.userInfo.nickName;
    }
    
    if (UserInfoManage.userInfo.token) {
        self.loginOutBtn.hidden = NO;
    }else{
        self.loginOutBtn.hidden = YES;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
